#include <typedef.h>

#if defined(CONFIG_TAR4ESP32)
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_pm.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#endif

// System include files
#include <console.hpp>
#include <mission_run.hpp>
#include <settings.hpp>
#include <storage.hpp>
#include <wifi.hpp>
#include <work_queue_utils.hpp>
// User include files
#include <adcatch.hpp>
#include <led.hpp>
#include <power.hpp>
#include <remoter.hpp>

#if defined(CONFIG_TAR4ESP32)
extern "C" void app_main(void)
#else
extern "C" int main(int argc, char* argv[])
#endif
{
	Storage::Instance()->Init();
	Wifi::Instance()->Start();
	Console::Instance()->Start();
	Settings::Instance()->Start();

	WorkQueueUtils::Instance()->Start(PRIORITY_WQ_HIGH, 8000, 100, "wq_high", E_CORE_1);
	WorkQueueUtils::Instance()->Start(PRIORITY_WQ_MID, 8000, 20, "wq_mid", E_CORE_0);
	WorkQueueUtils::Instance()->Start(PRIORITY_WQ_LOW, 8000, 5, "wq_low", E_CORE_0);

	Power::Instance()->Start();
	Remoter::Instance()->Start();

	Led led;
	led.On(0);
	led.Off(1);
	while (1)
	{
		led.Blink(0);
		led.Blink(1);
		usleep(100 * 1000);
	}

#if !defined(CONFIG_TAR4ESP32)
	return 0;
#endif
}
